﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media.Animation;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Media3D;
using System.Data;
using System.Reflection;
using System.Collections;
using System.Globalization;
using CrazyWorship1.PropertyHandler;
using System.Windows.Media;
using System.Windows.Shapes;
namespace CrazyWorship1.Transitions
{
    public class FadeSongIn : BaseSongTransitionIn
    {
        DoubleAnimation fade;
        public override void SetupTransition()
        {
            fade=new DoubleAnimation();
            fade.To=1;
            fade.Duration=new Duration(new TimeSpan(0,0,0));
            
        }
        [DataAttribute("FadeLength", typeof( IntPropertyHandler),"FadeSongInDefaultFadeLength")]
        public string FadeLength
        {
            get
            {
                return fade.Duration.TimeSpan.Seconds.ToString(CultureInfo.InvariantCulture);
            }
            set
            {
                fade.Duration = new TimeSpan(0, 0, 0, Convert.ToInt32(value, CultureInfo.InvariantCulture), 0);
            }
        }
        [DataAttribute("BeginTime", typeof(IntPropertyHandler), "FadeSongInDefaultBeginTime")]
        public string BeginTime
        {
            get
            {
                return fade.BeginTime.Value.Seconds.ToString(CultureInfo.InvariantCulture);
            }
            set
            {
                fade.BeginTime = new TimeSpan(0, 0, 0, Convert.ToInt32(value, CultureInfo.InvariantCulture), 0);
            }
        }
        [DataAttribute("FadeTo", typeof(DoublePropertyHandler), "FadeSongInDefaultFadeTo")]
        public string FadeTo
        {
            get
            {
                return fade.To.ToString();
            }
            set
            {
                fade.To = Convert.ToDouble(value, CultureInfo.InvariantCulture);
            }
        }
        public override void Go()
        {
            base.Go();
            StartAnimation(CurrentLyricTextBlock, TextBlock.OpacityProperty, fade);
             
            
        }
       
    }
   
}
